const merge = require('webpack-merge');
const webpackBaseConfig = require('./webpack.base.config');


const path = require('path');
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin')

webpackBaseConfig.plugins.forEach(function (plugin) {
    if (plugin.options && plugin.options.filename && plugin.options.template) {
        //针对HtmlWebpackPlugin
        plugin.options.minify = {
            //压缩HTML文件
            removeComments: true, //移除HTML中的注释
            collapseWhitespace: false //删除空白符与换行符
        };
    }
});


module.exports = merge(webpackBaseConfig, {
    mode: "production",
    output: {
        // publicPath: '/dist',  //模板、样式、脚本、图片等资源对应的server上的路径
    },
    devtool: 'source-map',
    plugins: [
        new webpack.DefinePlugin({
            'process.env.NODE_ENV': JSON.stringify('production')
        }),
        new ExtractTextPlugin({
            filename: 'css/[name].css' //路径以及命名
        })
    ],
    optimization: {
        minimizer: [new UglifyJSPlugin({
            sourceMap: true
        })]
    }

});




